package cn.handong.tool.设计模式.代理模式.动态代理814;

import java.io.FileOutputStream;
import java.io.OutputStream;

import sun.misc.ProxyGenerator;

public class runjdkproxytest {
        public static void main(String[] args) throws Exception{
            Dog dog = new Dog();
            ProxyFactory proxyfc = new ProxyFactory();
            proxyfc.setTarget(dog);
            Pet proxy = (Pet) proxyfc.createProxy();
            proxy.say();
            //这里用于生成代理类的字节码文件
//            byte[] bts = ProxyGenerator.generateProxyClass("DogProxy", new Class[]{Pet.class});
//            OutputStream out = new FileOutputStream("E:\\work\\myeclipsework\\DynamicProxy\\generateFile\\DogProxy.class");
//            out.write(bts);
        }
}
